﻿using System;
using System.Collections.ObjectModel;
using System.Windows;
using Nutshell.Components;
using Nutshell.Messaging;
using Nutshell.Messaging.Models;

namespace Nutshell.DLS.Business
{
        public class LogMessageCollection : Consumer<LogMessageModel>
        {
                public LogMessageCollection(string key = "")
                        : base(key)
                {
                        LogMessages = new ObservableCollection<LogMessage>();
                }

                public ObservableCollection<LogMessage> LogMessages { get; private set; }

                public virtual void Insert(LogMessageModel model)
                {
                        var message = new LogMessage();
                        message.Load(model);

                        Application.Current.Dispatcher.BeginInvoke(new Action(() => LogMessages.Add(message)));
                }
        }
}